<template>
  <div class="time-range-section">
    <h2>选择统计时间范围</h2>
    <div class="time-controls">
      <div class="time-input-group">
        <label>开始时间：</label>
        <input type="datetime-local" :value="startTime" @input="handleStartChange" />
      </div>
      <div class="time-input-group">
        <label>结束时间：</label>
        <input type="datetime-local" :value="endTime" @input="handleEndChange" />
      </div>
      <button @click="handleGenerate" class="btn-generate">生成报表</button>
    </div>

    <div class="quick-select">
      <button @click="emit('selectToday')" class="btn-quick">今天</button>
      <button @click="emit('selectWeek')" class="btn-quick">本周</button>
      <button @click="emit('selectMonth')" class="btn-quick">本月</button>
      <button @click="emit('selectAll')" class="btn-quick">全部</button>
    </div>
  </div>
</template>

<script setup lang="ts">
const props = defineProps<{
  startTime: string;
  endTime: string;
}>();

const emit = defineEmits<{
  'update:startTime': [value: string];
  'update:endTime': [value: string];
  generate: [];
  selectToday: [];
  selectWeek: [];
  selectMonth: [];
  selectAll: [];
}>();

const handleStartChange = (e: Event) => {
  emit('update:startTime', (e.target as HTMLInputElement).value);
};

const handleEndChange = (e: Event) => {
  emit('update:endTime', (e.target as HTMLInputElement).value);
};

const handleGenerate = () => {
  emit('generate');
};
</script>

<style scoped>
.time-range-section {
  margin-bottom: 24px;
  padding: 24px;
  background: white;
  border-radius: 12px;
  border: 2px solid #f0f4f8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

h2 {
  margin: 0 0 20px 0;
  color: #1e293b;
  font-size: 18px;
  font-weight: 600;
}

.time-controls {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-bottom: 15px;
}

.time-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time-input-group label {
  font-weight: 600;
  color: #475569;
  font-size: 15px;
}

.time-input-group input {
  padding: 11px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}

.time-input-group input:focus {
  border-color: #067ef5;
  background: white;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.btn-generate {
  padding: 11px 24px;
  background: #067ef5;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}

.btn-generate:hover {
  background: #0369a1;
  transform: translateY(-1px);
}

.quick-select {
  display: flex;
  gap: 12px;
}

.btn-quick {
  padding: 10px 20px;
  background: #f8fafc;
  color: #475569;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-quick:hover {
  background: #e0f2fe;
  border-color: #067ef5;
}
</style>

